package cn.fintecher.pangolin.service.dataimp.request;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

/**
 * @Auther: xiaqun
 * @Description: 警告查询请求参数
 * @Date: 11:12 2019/10/14
 */

@Data
public class FindWarningRequest {
    @ApiModelProperty(value = "批次号")
    private String batchNumber;

    @ApiModelProperty(value = "案件编号")
    private String caseNumber;

    public BoolQueryBuilder getBuilder() {
        BoolQueryBuilder builder = new BoolQueryBuilder();
        builder.must(QueryBuilders.matchPhraseQuery("batchNumber.keyword", this.batchNumber));
        if (StringUtils.isNotBlank(this.caseNumber)) {
            builder.must(QueryBuilders.wildcardQuery("caseNumber.keyword", this.caseNumber));
        }
        return builder;
    }
}
